package com.lxm.ymcc.service.impl;

import com.lxm.ymcc.domain.MessageSms;
import com.lxm.ymcc.dto.ReasonDto;
import com.lxm.ymcc.mapper.MessageSmsMapper;
import com.lxm.ymcc.service.IMessageSmsService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import java.util.Date;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author whale
 * @since 2022-10-22
 */
@Service
public class MessageSmsServiceImpl extends ServiceImpl<MessageSmsMapper, MessageSms> implements IMessageSmsService {

    @Override
    public void save(String title, String content, String phone) {
        MessageSms sms = new MessageSms();
        sms.setTitle(title);
        sms.setContent(content);
        sms.setPhone(phone);
        //ip-
        ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        //获取ip地址
        String addr = requestAttributes.getRequest().getRemoteAddr();
        sms.setIp(addr);
        //时间
        sms.setSendTime(new Date());
        //用户 如果登录用户 直接获取
        //sms.setUserId(1L);
        insert(sms);
    }
/*
    短信消息拉黑业务
 */
    @Override
    public void reason(ReasonDto reasonDto) {
        String phone = reasonDto.getPhone();
        String reason = reasonDto.getReason();
        String ip = reasonDto.getIp();



    }
}
